﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Entity;
namespace DAL
{
    public class EmployeeDB : DBAccess
    {
        public Employee employee;

        /// <summary>
        /// Return a Employee
        /// </summary>
        /// <param name="id"></param>
        /// <param name="pass"></param>
        /// <returns>Employee</returns>
        public Employee returnEmployee(int id, string pass)
        {
            try
            {
                SqlDataReader rd = ExecuteQuery("sp_login", CommandType.StoredProcedure, "@Id", id, "@pwd", pass);
                while (rd.Read())
                {
                    employee = new Employee();
                    employee.EmployeeId = int.Parse(rd["EmployeeId"].ToString());
                    employee.Name = rd["Name"].ToString();
                    employee.Indentify = rd["Indentify"].ToString();
                    employee.Password = rd["Password"].ToString();
                }
                return employee;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
    }
}
